package com.xpgk.mvc.codeSet;

import java.util.List;

import com.jfinal.log.Log;
import com.xpgk.dto.RenderBean;
import com.xpgk.dto.ZtreeNode;
import com.xpgk.mvc.base.BaseController;

public class CodeSetController extends BaseController{
	
	@SuppressWarnings("unused")
	private static final Log log = Log.getLog(CodeSetController.class);
	
	private CodeSetService codeService;
	
	public void index() {
		render("code.html");
	}
	
	/**
	 * CodeTree节点数据
	 */
	public void treeData() {
		List<ZtreeNode> nodeList = codeService.childNodeData(getCxt(), ids);
		renderJson(nodeList);
	}
	
	/**
	 * 跳转至添加
	 */
	public void toAdd() {
		setAttr("code", getModel(Code.class));
		render("addCode.html");
	}
	
	/**
	 * 添加
	 */
	public void addCode(){
		Code code = getModel(Code.class);
		RenderBean renderBean = codeService.addCode(code);
		renderJson(renderBean);
		
	}
	
	/**
	 * 跳转至更新
	 */
	public void toUpdate() {
		setAttr("code", Code.dao.findById(ids));
		render("updateCode.html");
	}
	
	/**
	 * 修改
	 */
	public void upCode(){
		Code code = getModel(Code.class);
		RenderBean renderBean = codeService.updateCode(code);
		renderJson(renderBean);
	}
	
	/**
	 * 删除
	 */
	public void delCode(){
		String result = codeService.deleteCode(ids);
		renderText(result);
	}
	
	/**
	 * 参数列表
	 */
	public void codeList() {
		String json = paging(splitPage, Code.sqlId_splitPageSelect, Code.sqlId_splitPageFrom);
		renderJson(json);
	}
}
